package com.edu.study.base.wordAttributeDetail.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.wordAttributeDetail.domain.WordAttributeDetail;
import com.edu.study.base.wordAttributeDetail.service.IWordAttributeDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单词测试选项内容Controller
 * 
 * @author zw
 * @date 2021-08-02
 */
@RestController
@RequestMapping("/wordAttributeDetail/wordAttributeDetail")
public class WordAttributeDetailController extends BaseController
{
    @Autowired
    private IWordAttributeDetailService wordAttributeDetailService;

    /**
     * 查询单词测试选项内容列表
     */
    @PreAuthorize("@ss.hasPermi('wordAttributeDetail:wordAttributeDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(WordAttributeDetail wordAttributeDetail)
    {
        startPage();
        List<WordAttributeDetail> list = wordAttributeDetailService.selectWordAttributeDetailList(wordAttributeDetail);
        return getDataTable(list);
    }

    /**
     * 导出单词测试选项内容列表
     */
    @PreAuthorize("@ss.hasPermi('wordAttributeDetail:wordAttributeDetail:export')")
    @Log(title = "单词测试选项内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WordAttributeDetail wordAttributeDetail)
    {
        List<WordAttributeDetail> list = wordAttributeDetailService.selectWordAttributeDetailList(wordAttributeDetail);
        ExcelUtil<WordAttributeDetail> util = new ExcelUtil<WordAttributeDetail>(WordAttributeDetail.class);
        return util.exportExcel(list, "wordAttributeDetail");
    }

    /**
     * 获取单词测试选项内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('wordAttributeDetail:wordAttributeDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wordAttributeDetailService.selectWordAttributeDetailById(id));
    }

    /**
     * 新增单词测试选项内容
     */
    @PreAuthorize("@ss.hasPermi('wordAttributeDetail:wordAttributeDetail:add')")
    @Log(title = "单词测试选项内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WordAttributeDetail wordAttributeDetail)
    {
        return toAjax(wordAttributeDetailService.insertWordAttributeDetail(wordAttributeDetail));
    }

    /**
     * 修改单词测试选项内容
     */
    @PreAuthorize("@ss.hasPermi('wordAttributeDetail:wordAttributeDetail:edit')")
    @Log(title = "单词测试选项内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WordAttributeDetail wordAttributeDetail)
    {
        return toAjax(wordAttributeDetailService.updateWordAttributeDetail(wordAttributeDetail));
    }

    /**
     * 删除单词测试选项内容
     */
    @PreAuthorize("@ss.hasPermi('wordAttributeDetail:wordAttributeDetail:remove')")
    @Log(title = "单词测试选项内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wordAttributeDetailService.deleteWordAttributeDetailByIds(ids));
    }
}
